package cc.wsyw126.java;

import cc.wsyw126.java.model.User;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by junpeng.yang on 17/1/19.
 */
public class test {
    public static void main(String[] args) {
        HashMap<User, Integer> objectObjectHashMap = new HashMap<>();
        User user = new User();
        user.setName("asd");
        user.setId(1);

        objectObjectHashMap.put(user, 1);

        user.setId(3);


        User user1 = new User();
        user1.setName("asd");
        user1.setId(1);

        objectObjectHashMap.put(user1, 2);
        objectObjectHashMap.put(user1, 3);

        for (Map.Entry<User, Integer> userIntegerEntry : objectObjectHashMap.entrySet()) {
            System.out.println("userIntegerEntry.getValue() = " + userIntegerEntry.getValue());
            System.out.println("userIntegerEntry.getKey() = " + userIntegerEntry.getKey());
        }


        System.out.println(objectObjectHashMap.get(user));
        System.out.println(objectObjectHashMap.get(user1));

    }
}
